Open
Conversation
Invoice already has an `errors` field, but LineItem and Transaction did not. Add `errors = fields.Dict(allow_none=True)` to both schemas so validation errors returned by the API are accessible on nested objects. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add `id` field to Account schema so the account identifier is accessible. Add `churn_recognition` and `churn_when_zero_mrr` fields to support the optional `include` query parameter on the /account endpoint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Invoice.update_status (PATCH /invoices/{uuid}) for updating invoice
status and Invoice.disable (PATCH /invoices/{uuid}/disable) for
disabling invoices.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add SubscriptionEvent.destroy() and .modify() that accept flat params
(e.g. data={"id": 123}) and auto-wrap in the subscription_event
envelope. The old _with_params methods are preserved for backwards
compatibility.
Add SubscriptionEvent.disable() and .enable() convenience methods
for toggling the disabled state of subscription events.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add edge case, error path, and backwards-compatibility tests: Invoice: - Verify update_status request body is sent correctly - 404 error paths for update_status and disable - Verify disable sends no request body - LineItem/Transaction errors=None and errors-absent cases SubscriptionEvent: - Flat destroy/modify with external_id+data_source_uuid - Passthrough when caller already wraps in envelope (no double-wrap) - disable/enable with external_id+data_source_uuid identification Account: - Graceful handling when id field absent from response - Single include param Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the Python SDK to support additional API response fields and adds/adjusts client methods for invoice and subscription event operations, with accompanying test coverage.
Changes:
- Add deserialization support for
errorson invoice line items/transactions and for additional account fields (id, churn settings). - Add invoice endpoints for updating status and disabling invoices.
- Add
SubscriptionEvent.destroy/modify/disable/enablehelpers that accept “flat” params and wrap them in the requiredsubscription_eventenvelope, plus tests for these behaviors.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
chartmogul/api/transaction.py |
Adds errors field support on Transaction schema. |
chartmogul/api/invoice.py |
Adds errors support on invoice-related schemas and introduces update_status / disable methods. |
chartmogul/api/account.py |
Extends Account schema with optional id and churn-related fields. |
chartmogul/api/subscription_event.py |
Adds wrapper methods to accept flat params and to enable/disable subscription events. |
test/api/test_invoice.py |
Adds tests for nested errors fields and new invoice status/disable endpoints. |
test/api/test_account.py |
Adds tests for newly supported account fields and include query behavior. |
test/api/test_subscription_event.py |
Adds tests for flat-parameter wrapping and enable/disable helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
errorsfield onLineItemandTransactionschemas (Invoice already had it)id,churn_recognition,churn_when_zero_mrrfields toAccountschema; supportincludequery param on/accountInvoice.update_status(PATCH) andInvoice.disable(PATCH/invoices/{uuid}/disable)destroy()/modify()wrappers that accept flat params instead of requiringsubscription_event: {...}envelope; adddisable()/enable()convenience methodsTest plan
Manual testing instructions
Prerequisites
PIP-304: Validation errors on LineItem and Transaction
What to test: When retrieving an invoice,
line_items[].errorsandtransactions[].errorsare now accessible (previously onlyinvoice.errorswas exposed).Expected: Each line item and transaction prints its
errorsvalue (Nonefor valid items, or a dict of validation errors). NoAttributeErroris raised.PIP-120: Account ID in response
What to test:
Account.retrieve()now exposes theidfield.Expected:
account.idprints a string like"acct_...". NoAttributeError.PIP-76: Include params on Account endpoint
What to test: Pass
includequery param to retrieve additional account fields.Expected: Both fields are returned with string values (e.g.
"immediate","ignore"). Withoutinclude, these fields would not be present in the response.Invoice update-status endpoint
What to test:
Invoice.update_status()sends a PATCH to/invoices/{uuid}.Expected: The invoice is updated and
result.disabledisTrue. The API returns the full invoice object.Invoice disable endpoint
What to test:
Invoice.disable()sends a PATCH to/invoices/{uuid}/disablewith no request body.Expected: The invoice is disabled.
result.disabledisTrue.Error case — missing uuid:
Expected: Raises
ArgumentMissingErrorwith message about missinguuidparameter.SubscriptionEvent: flat params for modify/destroy
What to test: New
destroy()andmodify()accept flat params without thesubscription_eventenvelope.Expected: Both flat and envelope-wrapped calls work. The SDK auto-wraps flat params into
{"subscription_event": {...}}before sending.SubscriptionEvent: disable/enable toggling
What to test: New
disable()andenable()convenience methods.Expected: Each call succeeds. The SDK sets
disabled: true/falseinside thesubscription_eventenvelope automatically.🤖 Generated with Claude Code